package com.coocaa.aries.dashboard.v1.dict.service.impl;

import com.coocaa.aries.core.base.model.PageResultModel;
import com.coocaa.aries.core.base.mybatis.QueryTemplate;
import com.coocaa.aries.core.tool.InstanceUtil;
import com.coocaa.aries.dashboard.v1.dict.biz.impl.ExtDictInfoBizImpl;
import com.coocaa.aries.dashboard.v1.dict.entity.ExtDictInfoEntity;
import com.coocaa.aries.dashboard.v1.dict.model.ExtDictInfoModel;
import com.coocaa.aries.dashboard.v1.dict.service.IExtDictInfoQueryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * @author bjh
 * @description aries数据字典信息表-查询service接口实现
 * @date 2020-03-05 16:31:24
 */
@Service
public class  ExtDictInfoQueryServiceImpl implements IExtDictInfoQueryService {
    @Autowired
    private ExtDictInfoBizImpl extDictInfoBiz;



    /**
    * 分页数据-菜单自己使用
    *
    * @param model
    * @return
    */
    @Override
    public PageResultModel<ExtDictInfoEntity> pageList(ExtDictInfoModel model){
        PageResultModel<ExtDictInfoEntity> pageResultModel=extDictInfoBiz.getCommonPageResult(model);
        return pageResultModel;
    }

    @Override
    public List<ExtDictInfoEntity> queryByType(String type) {
        QueryTemplate<ExtDictInfoEntity> queryTemplate = QueryTemplate.getEqQueryTemplate("type", type);
        queryTemplate.orderByDesc("last_update_date");
        if (extDictInfoBiz.getMapper().selectCount(queryTemplate) > 0){
            return extDictInfoBiz.getMapper().selectList(queryTemplate);
        }
        return InstanceUtil.newArrayList(0);
    }
}
